package com.emar.adx.yiqifa.algorithm;

import java.util.Arrays;

/**
 * Created by xiaoliang
 * 2016/10/9 10:04
 *
 * @Version 1.0
 */
public class BubbleSort {

    int[] datas = SortConstants.DATA_ARRAYS;

    public void sort(){
        System.out.println("0--> "+Arrays.toString(datas));
        int num = 1;

        for(int i = datas.length -1;i>0;i--){
            for(int j = 0;j<i;j++){
                if(datas[j] > datas[j+1]){
                    int tmp = datas[j];
                    datas[j] = datas[j+1];
                    datas[j+1] = tmp;
                }
            }
            System.out.println(num + "--> "+Arrays.toString(datas));
            num ++ ;
        }
    }
}
